﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameStart : MonoBehaviour {
    public GameMode GameMode;
    public bool OpenLog;
	void Start() {
        Manager.Event.Subscribe(10000, OnLuaInit);

        Appconst.GameMode = this.GameMode;
        Appconst.OpenLog = this.OpenLog;
        //该节点不可销毁
        DontDestroyOnLoad(this);

        //执行lua代码
        Manager.Resource.PraseVersionFile();
        Manager.Lua.Init();
        
	}

    void OnLuaInit(object args)
    {
        Manager.Lua.StartLua("main");
        //XLua.LuaFunction func = Manager.Lua.LuaEnv.Global.Get<XLua.LuaFunction>("Main");
        //func.Call();
        Manager.Pool.CreateGameObjectPool("UI", 5);
        Manager.Pool.CreateGameObjectPool("Entity", 120);
        Manager.Pool.CreateGameObjectPool("Monster", 120);
        Manager.Pool.CreateAssetPool("AssetBundle", 5);
    }

    public void OnApplicationQuit()
    {
        Manager.Event.UnSubscribe(10000, OnLuaInit);
    }

}
